<template>
  <div class="demo">
      <h2>学校名字:{{myName}}</h2>
      <h2>学校年龄:{{age}}</h2>
      <button @click="sendSchoolName">把学校名给App</button>
  </div>
</template>

<script>

export default {
    name:'SchoolS',
    props:['getSchoolName'],
    data(){
        return {
            msg:"自我介绍",
            age:'66',
            myName:"123"
        }
    },
    methods: {
        sendSchoolName(){
            this.getSchoolName(this.msg)


        }
    },
    mounted() {
        this.$bus.$on('hello',(am)=>{
            console.log('收到了',am);
        })
    },
    beforeDestroy() {
        //由于都会将事件放在总线上，造成总线东西太多了，所以最好在组件被销毁的时候，将这个释放掉
        this.$bus.$off('hello')
    },
}
</script>


<style scoped>
    .demo{
        background-color: blue;
    }
</style>